/*
	kernel_fixed_table.h

	contains the definition for the kernel fixed table
	the table is located at 0x100000 (1MB) in physical memory
	or 0xffffff8000100000 in virtual memory

	Author: Aidan Goddard 14/7/14
*/

#ifndef KERNEL_FIXED_TABLE_H_INCLUDED
#define KERNEL_FIXED_TABLE_H_INCLUDED

#include "types.h"
#include "memory_tables.h"

#define KERNEL_FIXED_TABLE_SIZE 4096

// system states
typedef uint64_t SYSTEM_STATE;
#define SYSTEM_STATE_BOOT ((SYSTEM_STATE)0)
#define SYSTEM_STATE_STARTUP ((SYSTEM_STATE)1)
#define SYSTEM_STATE_NOT_SCHEDULING ((SYSTEM_STATE)2)
#define SYSTEM_STATE_SCHEDULING ((SYSTEM_STATE)3)


struct kernel_fixed_table
{
	// floating table pointers
	// memory system pointers
	struct lazy_invalidation_table *lazy_invalidation_tables;
	struct lazy_invalidation_global_free_table *lazy_invalidation_global;

	void *reserved[254];

	// core control variables
	uint64_t CPU_count;
	SYSTEM_STATE system_state;


	volatile uint64_t reserved2[254];
};

// static pointer to the table
static struct kernel_fixed_table *KERNEL = (struct kernel_fixed_table*)(KOFFSET + 0x100000);



#ifdef __GCC_CROSS__
_Static_assert ((sizeof(struct kernel_fixed_table) == 4096), "kernel_fixed_table structure is not the expected size");
#endif

#endif